export default {
  name: '用户管理',
  api: [
    {
      name: 'insert',
      url: '',
      method: 'post'
    },
    {
      name: 'update',
      url: '/user/update',
      method: 'post'
    },
    {
      name: 'delete',
      url: '/user/delete',
      method: 'post'
    },
    {
      name: 'query',
      url: '/user/list',
      method: 'get'
    }
  ],
  fields: [
    {
      type: 'selection',
      width: '55',
      align: 'center'
    },
    {
      label: '排名',
      prop: 'index',
      align: 'center'
    },
    {
      prop: 'name',
      label: '姓名',
      width: 150,
      filter: true,
      filterProps: {
        type: 'el-input',
        placeholder: '请输入姓名',
        clearable: true
      },
      form: 'el-input',
      validator: "if(value === 'xxxx') {\n  return true\n}\nreturn 'xxxxxxx不合格'",
      table: true
    },
    {
      prop: 'account',
      label: '登录账号',
      width: 200,
      form: 'el-input',
      filter: true,
      filterProps: {
        type: 'el-input',
        placeholder: '请输入登录账号',
        clearable: true
      }
    },
    {
      prop: 'phone',
      label: '手机号',
      width: 250,
      form: 'el-input'
    },
    {
      prop: 'email',
      label: '邮箱',
      width: 250,
      form: 'el-input'
    },
    {
      prop: 'role',
      label: '角色',
      width: 100,
      form: 'el-select',
      options: [
        {
          label: '管理员',
          value: 'admin'
        },
        {
          label: '普通用户',
          value: 'user'
        },
        {
          label: '测试用户',
          value: 'test'
        },
        {
          label: '超级用户',
          value: 'root'
        },
        {
          label: '超级管理员',
          value: 'super'
        }
      ],
      filter: 'el-select',
      filterProps: {
        placeholder: '请选择角色',
        clearable: true
      }
    },
    {
      prop: 'sex',
      label: '性别',
      width: 100,
      form: 'el-radio-group',
      options: [
        {
          label: '男',
          value: 1
        },
        {
          label: '女',
          value: 2
        }
      ]
    },
    {
      prop: 'state',
      label: '状态',
      width: 100,
      form: 'el-select',
      asyncOptions: "return http.get('/common/status.json').then(res => res.data)"
    },
    {
      prop: 'remark',
      label: '备注',
      width: 100,
      table: false,
      form: 'el-input',
      show: false,
      props: {
        rows: 4,
        type: 'textarea',
        placeholder: '请输入内容xxxxx',
        maxlength: 300,
        showWordLimit: true
      }
    },
    {
      prop: 'creatData',
      label: '创建时间',
      width: 200
    }
  ],
  pagination: {
    total: 0,
    samll: true,
    pageSize: 50,
    background: true,
    layout: 'total, prev, pager, next, sizes'
  },
  actions: [
    {
      label: '工作台',
      position: '1',
      event: 'toWork',
      link: true,
      type: 'primary',
      action: "this.request.post('/api/set/xxx',data.row)"
    },
    {
      label: '编辑',
      position: '1',
      event: 'onEdit',
      link: true,
      type: 'primary',
      // action: 'console.log("编辑", data)'
      action:
        'this.formData.value = data.row;this.dialog.visible = true;\nthis.dialog.title = "编辑"'
    },
    {
      label: '详情',
      position: '1',
      link: true,
      event: 'showDetail',
      action: 'this.$refs.form.detail(data, this.table)'
    },
    {
      label: '设置',
      position: '1',
      link: true,
      event: 'toSetting',
      action: "console.log('设置', data)"
    },
    {
      label: '新增',
      position: '2',
      event: 'onAdd',
      type: 'primary',
      action: 'this.dialog.visible=true;\nthis.formData.value={};\nthis.dialog.title="新增"'
    },
    {
      label: '删除',
      position: '2',
      event: 'onDelete',
      type: 'danger',
      action: `
        var list=this.selection.value.map(i => i.id);
        this.tableData.value=this.tableData.value.filter(i=>!list.includes(i.id))
      `
    }
  ],
  tableConfig: {
    border: true,
    height: 590,
    showIndex: true,
    showSelection: true
  },
  tableOperater: {
    width: 250,
    label: ''
  },
  formConfig: {
    labelWidth: '120px',
    style: 'max-width: 500px; margin:auto;padding-right:100px'
  }
};
